//
//  UICurveView.h
//  NTempure
//
//  Created by longkin on 15/1/31.
//  Copyright (c) 2015年 elsonic.inc. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "UIColor+HTML.h"


struct ChartBlock {
    CGFloat begin;//开始值
    CGFloat interval;//间隔数值
    CGFloat width;//间隔宽度
    NSInteger count;//显示数量
};
typedef struct ChartBlock ChartBlock;
CG_INLINE ChartBlock
ChartBlockMake(CGFloat begin, CGFloat interval, CGFloat width, NSInteger count)
{
    ChartBlock chartblock;
    chartblock.begin = begin;
    chartblock.interval = interval;
    chartblock.width = width;
    chartblock.count = count;
    return chartblock;
}
//=======

struct HourTempureValue{
    NSInteger hour;//
    CGFloat tempure;
};
typedef struct HourTempureValue HourTempureValue;

CG_INLINE HourTempureValue
HourTempureValueMake(NSInteger hour, CGFloat tempure)
{
    HourTempureValue value;
    value.hour = hour;
    value.tempure = tempure;
    return value;
}

/************************************************************************************/

@interface NSValue (HourTempureValue)

+ (NSValue *)valueWithHourTempure:(HourTempureValue)hourtemp;
- (HourTempureValue)hourTempureValue;

@end

/************************************************************************************/

@protocol UICurveViewDelegate;


/************************************************************************************/

@interface UICurveView : UIControl
{
@private
    CGPoint zeroPoint;
    UIFont *font;
    NSDictionary *_textStyleDict;
    UILongPressGestureRecognizer *longPress;
    UITapGestureRecognizer *tap;
}

//@property (nonatomic) CGRect curveRect;//曲线绘制区域
@property (nonatomic,retain) NSString *xLineUnit;//x轴单位
@property (nonatomic,retain) NSString *yLineUnit;//y轴单位
@property (nonatomic) ChartBlock xChartBlock;
@property (nonatomic) ChartBlock yChartBlock;
@property (nonatomic,retain) NSArray *curveItems;//CurveModel 数组,支持多个曲线显示
@property (nonatomic,assign) id<UICurveViewDelegate> delegate;

@end

/************************************************************************************/

@interface CurveModel : NSObject
{
@private
    NSMutableArray *_points;
}
@property (nonatomic) NSInteger curveID;
@property (nonatomic,retain) NSString *name;
@property (nonatomic,retain) UIColor *lineColor;
@property (nonatomic,retain) UIColor *fillColor;
@property (nonatomic,retain) NSArray *hourtempures;
@property (nonatomic,retain,readonly) NSArray *points;
@property (nonatomic,assign) NSUInteger type;

- (NSComparisonResult)compareCurve:(CurveModel *)model;

@end


/************************************************************************************/

@protocol UICurveViewDelegate <NSObject>

-(void)curveView:(UICurveView *)sender longPressed:(CurveModel *)model;

@end
